********Figure 2 - Mexico********

cd "$reploc/data"
use Mex_prov_timeseries.dta, clear

append using Mex_timeseries.dta

forval yr=1941/2014 {
replace gdpgr`yr'=mex_gr`yr' if idmex==1
}

replace state="Mexico (State)" if state=="Mexico"
replace state="Mexico" if idmex==1
replace provcode=111111 if idmex==1

drop mex_gr* idmex
drop if provcode==.

reshape long gdpgr, i(provcode) j(year)

*Winsorize data
winsor gdpgr if provcode!=111111, p(0.05) gen(gdpgr_wins)
sort provcode year

*Plot
tsset provcode year
drop if year<1941 | year>2015


local provcodesgrey 1 3 4 5 6 7 8 9 10 11 12 13 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

local plotinum
local legi legend()

foreach progrey in `provcodesgrey' {
local plotinum `plotinum' (line gdpgr_wins year if provcode==`progrey', lcolor(gs12))
local legi `legi' label(1 "")
}

local plotinum1 `plotinum' (line gdpgr_wins year if provcode==3, lcolor(orange) lwidth(#10)) (line gdpgr_wins year if provcode==14, lcolor(magenta) lwidth(#10)) (line gdpgr year if provcode==111111, lcolor(black) lwidth(medthick))

twoway `plotinum1', legend(order(31 "Baja California Sur" 32 "Jalisco" 33 "Mexico") rows(1)) ytitle("GDP Growth (%)") xtitle("Year") graphregion(color(white)) ysc(r(-20 20)) ylabel(-20(10)20)

cd "$reploc/results"
graph export Figure2Mexico.eps, replace
